<?php
class Ftp_Class
	{
		private $username=null;
		private $pwd=null;
		private $connection=null;
		private $url=null;
		
		
		public function __construct()
			{
				
			}
		
		private set_username($name)
			{
				$this->username=$name;
			}
			
		private set_pwd($pwd)
			{
				$this->pwd;
			}
			
		public get_instance($username,$pwd,$url)
			{
				//$this->set_params();
				$this->username=$username;
				$this->pwd=$pwd;
				$this->url=$url;
				
				if($this->username && $this->pwd && $this->url)
					{
						$this->connection=ftp_connect($this->url);
						ftp_login($this->connection,$this->username,$this->pwd);
						return true;
					}
					else
						{
							return false;
						}
			}
		//上传文件
		public function putfile($file,$newfile)
			{
				ftp_put($this->connection,$newfile,$file,FTP_BINARY);
			}
		//下载文件
		public function getfiel($file,$newfile)
			{
				ftp_get($this->connection,$newfile,$file,FTP_BINARY);
			}
		
		private function dirlist($dir=".")
			{
				$list=ftp_nlist($this->connection,$dir);
				return $list;
			}
		
		private function ftpmkdir($dir=null)
			{
				if($dir)
					{
						ftp_mkdir($this->connection,$dir);
					}
				
			}
		
		private function ftprmdir($dir=null)
			{
				if($dir)
					{
						ftp_rmdir($this->connection,$dir);
					}
				
			}
		
		private function ftppwd()
			{
				return ftp_pwd($this->connection);
			}
		
		public function ftpclose()
			{
				ftp_close($this->connection);
			}
		
	}


?>